home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 4thcmp21.zip / ROMGO.4TH < prev    next >
Text File  |  1993-06-23  |  3KB  |  91 lines

  1. 0 #IF
  2. SAMPLE STARTUP CODE FOR ROMMABLE APPLICATIONS
  3.  
  4. COPYRIGHT 1985 (C) BY THOMAS ALMY.  ALL RIGHTS RESERVED
  5.  
  6. Permission is granted to registered users of ForthCMP to sell or distribute
  7. computer programs incorporating the compiled contents of this file.
  8.  
  9. MS is a trademark of Microsoft Corporation.
  10.  
  11. This file is for ROMABLE FILES.  It will need to be modified
  12.   for particular situations.  The generated file has a COM
  13.   extension, but is not executable under MS-DOS.  Compile and
  14.   use the program UNLOAD to convert to INTEL HEX Format.
  15.  
  16.  
  17. To run a rommable program, you must jump to the start of the ROM.
  18. The segment location of the ROM is not important, the code is relocatable
  19.  
  20. To run the program as a separate data segment .COM DOS program, see
  21. comments with *
  22.  
  23. #THEN
  24.  
  25. \ Fill in these with the appropriate values
  26. HEX
  27. \ * FOR DOS romoffset must be 100, ramseg needs to be set to a "safe"
  28. \ * location near the top of the base memory address space, such as 8000
  29. 0 CONSTANT romoffset \ offset from start of segment for code ROM
  30. 1000 CONSTANT ramseg \ Segment RAM starts in.
  31. 0 CONSTANT ramoffset \ offset from start of segment for program RAM
  32. 1000 CONSTANT ramend \ offset from start of segment of end of RAM
  33.  
  34. \ use the following when a separate stack segment is desired
  35. \ * FOR DOS, stackseg must be set to a safe location near the top of the
  36. \ * base memory, but not conflicting with the data segment
  37. 2000 CONSTANT stackseg \ segment of stack RAM
  38. 1000 SEPSSEG        \ states stack segment 1000 bytes long
  39.  
  40. \ Use the following to have the data segment initialized from ROM
  41. \ * You will need to initialize if the DOS I/O functions are being used
  42. \ * for development.
  43.  
  44. INITIALIZE
  45.  
  46. \ Back to common code
  47.  
  48. \ Size of return stack is third argument below. It get assigned to rssize.
  49.  
  50. ramoffset romoffset 100 ROMABLE \ sets up program format
  51.  
  52. ASM HEX FWD,  ( skip the variables )      HEX  DSEG
  53. VARIABLE DP       ( start free ram = HERE )
  54. VARIABLE S0       ( top of stack )
  55. VARIABLE R0       ( top of return stack )
  56. VARIABLE BASE  0A BASE ! ( initialized at runtime )
  57. initial? #IF CSEG CREATE SEGOFFSET 0 ,
  58.       #ELSE  CSEG CREATE INITDP 0 , #THEN
  59. THEN,
  60. ramseg # AX MOV  AX DS >SEG  \ Set DS
  61. SEPSSEG? #IF stackseg # AX MOV AX SS >SEG 
  62.              pssize 10 * rssize - # SP MOV 
  63.          pssize 10 * # BP MOV
  64. #ELSE
  65.    AX SS >SEG ramend rssize - # SP MOV
  66.    ramend # BP MOV
  67. #THEN
  68.    CLD
  69. initial? #IF  \ initialize it all
  70.    DS PUSHSEG  ES POPSEG
  71.    AX CS <SEG  CS: SEGOFFSET [] AX ADD AX DS >SEG \ source seg is end of code
  72.    SI SI XOR  ramoffset # DI MOV    \ OFFSETS 
  73.    ' DP [] CX MOV  \ "here" as indicated in the ROM
  74.    DI CX SUB       \ # bytes to move   
  75.    REPZ BYTE MOVS  \ move the bytes
  76.    ES PUSHSEG DS POPSEG
  77. #ELSE \ we must at least initialize BASE and DP
  78.    0A # BASE [] MOV  
  79.    CS: INITDP [] AX MOV AX DP [] MOV 
  80. #THEN
  81. BP R0 [] MOV \ initialize R0
  82. SP AX MOV AX DEC AX DEC AX S0 [] MOV     \ initialize S0
  83. 0 0 IN/OUT NEED MAIN
  84. CALL' MAIN   ( call main program )
  85. \ * For DOS, replace the following code with
  86. \ *  4C # AX MOV 21 INT 
  87.  
  88. CODE bye 0F4 C, END-CODE ( HALT )
  89. FORTH DECIMAL  DSEG
  90.  
  91.